<extend name="layout/edit" />

<block name="HEADER">
	<style type="text/css">
		#can_day{
			padding-right: 170px !important;
		}
        #benefit_discount{
        	padding-right: 210px !important;
        }
       input[name='benefit_cond']{
       		padding-right: 85px !important;
       		
       }
	</style>
</block>

<block name="CONTENT">
    <control:form id="form"/>
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
		ns.init = function(){



        }


        //保存
        ns.save=function(){   
        	var data = form.getData();
        	if( !data ) {  return false; }

            var goodData = form.$grids['goodGrid'].getRows();
            var shopData = form.$grids['ShopGrid'].getRows();
            if( data.start_time >= data.stop_time ){
				$.alert(0,"开始时间不能大于等于结束时间！");
				return false;
			}

            form.save(4).then(function(res){
                 //异步保存多个商品到优惠券下
                $.ajaxs('/admin/v1/activity_discount/setcoupongs',{
                    coupon_id:res.data,
                    goodData: JSON.stringify(goodData),
                    goodcateDate: JSON.stringify(shopData),
                }).then(function(res){
                    form.opener.grid.load();
                    $.close();
                });

            });
        }
        
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>



